package Servlet.ComprobantePago;

import java.io.IOException;
import java.util.Collection;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.huellas.bean.Comprobante;
import com.huellas.bean.ReporteAtencionDiaria;
import com.huellas.negocio.GestionComprobantes;

/**
 * Servlet implementation class ComprobantePagoServlet
 */
@WebServlet("/ComprobantePagoServlet")
public class ComprobantePagoServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ComprobantePagoServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String code = request.getParameter("txtCodigo").toString();
		if(code == ""){
			code = "0";
		}
		
		int codigo = Integer.parseInt(code);
		if (codigo == 0) {codigo = 0;}; 
		GestionComprobantes gComprobante = new GestionComprobantes();
		Collection<Comprobante> ListaComprobante = null;
		try {
			if(codigo == 0 ){
			ListaComprobante = gComprobante.ListarComprobante(0, "L");
			}else {
			ListaComprobante = gComprobante.ListarComprobante(codigo, "S");	
			}
			
			request.setAttribute("ListarComprobanteReporte", ListaComprobante);
			RequestDispatcher rd = request.getRequestDispatcher("ComprobantePago.jsp");
			rd.forward(request, response);
		} catch (Exception e) {
			// TODO: handle exception
		}
		
	}

}
